home *** CD-ROM | disk | FTP | other *** search
- CH 12 − SCRIPT FILES
- ====================
- Powerbase incorporates a script language which lets you control some
- features from a script file. Using script files you can automate jobs which
- need to be done frequently. Print jobs are the most obvious example, and
- most of the script commands concern printing. Script files are plain text
- files (created with Edit) and are executed by dragging them to the main
- Powerbase window. All commands in a script file must be in upper-case,
- preceded by “!”, and may be followed by a parameter, separated from the
- command by a single space. The following commands may be used (parameters in
- square brackets are optional):−
-
- !SCRIPT All script files must begin with the line !SCRIPT POWERBASE. This
- enables the program to distinguish a script from other text files. You
- should make !SCRIPT END the last line of the file. The command can be made
- to “chain” another script file by following it with the name of the new
- file, i.e. by using the form !SCRIPT <filename>.
-
- !COMMENT may be used to insert comments in a script file. The rest of the
- line after the command is ignored.
-
- !SELECTION <filename> where <filename> is the name of a selection file in
- the PrintRes directory, installs the selection as if you had dragged it from
- PrintRes to the Powerbase window yourself. If you issue the command without
- a parameter the current selection will be cleared.
-
- !PRINTOPTS <filename> where <filename> is the name of a print options file
- in the PrintRes directory, sets the print options just as if the the file
- had been dragged from PrintRes to the Powerbase window. Issued without a
- parameter causes the default options to be set.
-
- !QUERY [filename,]<search formula> is used to print a list. It returns the
- same result as typing the search formula into the Print window and clicking
- Print. If you first issue a !DESTINATION File command you can use a script
- containing a list of !QUERY commands to create a batch of reports as text
- files. If the optional filename is omitted each file will be created in
- PrintJobs using the search formula (or its leftmost 10 characters) as the
- filename. If you supply a name containing $ it is assumed to be a full
- pathname and will be used to create the file. Any other name cuases the file
- to be created in PrintJobs or in a subdirectory (which must exist) of Print
- Jobs. !CASE and !INDEX also affect the behaviour of this command if issued
- beforehand.
-
- !CSV [filename,]<search formula> resembles !QUERY but produces a CSV file
- instead. The CSV option settings are observed. A !DESTINATION command is,
- of course, unnecessary.
-
- !EXPAND is one of a number of commands used to select or deselect a switch
- in the Print options window. !EXPAND ON selects the switch which causes
- fields to be expanded by reference to a linked validation table. !EXPAND OFF
- (or just !EXPAND by itself) deselects the switch.
-
- !DATE turns date and time stamping ON and OFF. It works in exactly the same
- way as !EXPAND.
-
- !UPPER forces upper-case printing when followed by ON, normal upper/lower
- case printing otherwise.
-
- !UNDERLINE turns underlining ON and OFF when output is sent to the printer.
- Underlining won’t be visible when the report is displayed in a window, but
- will occur when the output is subsequently printed.
-
- !CASE turns the Case switch on the Query panel ON and OFF.
-
- !HEADER followed by ON causes header information (see 3.5) to be printed on
- reports.
-
- !FIRST followed by ON causes the header to appear on the first page only.
-
- !FOOTER followed by ON causes footer information (see 3.5) to be printed on
- reports.
-
- !SHRINK followed by ON this removes surplus “white space” between the
- columns of reports in Vertical format.
-
- !HEADINGS D causes descriptors to be used as field identifiers in a report.
- !HEADINGS T, or without any parameter, causes tags to be used.
-
- !PITCH <n> sets the number of characters per inch for hard-copy printing to
- n, which should be 5, 10, 12 or 17, representing double-width, pica, elite
- and condensed respectively.
-
- !TITLE <string> uses <string> as a title on subsequently printed reports.
-
- !PAGE <n> sets the page length for reports to n lines. 70 is correct for A4,
- 66 for American letter.
-
- !LINESPACE <n> sets the line-spacing to n lines. The default is 1, i.e. no
- blank lines between lines of report. 2 gives double-spacing
-
- !LMARGIN <n> sets the left margin to n character spaces.
-
- !TMARGIN <n> sets the top margin to n lines.
-
- !SPACER <string> specifies the string to be used to separate columns of
- printed data in reports using Horizontal or Table format.
-
- !COLWIDTH <n> sets the width of the blank columns used in Table format to n
- spaces.
-
- !FORMAT <string> where <string> is Horizontal, Vertical, Label or Table
- (N.B. case of <string> does not matter), sets the print format. In the last
- case the number of columns required must be appended as a second parameter,
- e.g. TABLE 8. If any other parameter is used, or !FORMAT is issued by
- itself, the Horizontal format is used.
-
- !DESTINATION <string> where <string> is Window, File or Printer (N.B. case
- of <string> does not matter), sets the destination for report printing (see
- 3.1). If File is used the report is saved in PrintJobs unless a subsequent
- !QUERY command supplies an alternative pathname (see above).
-
- !LABEL is used to define a label specification to use with the LABEL format.
- It requires seven parameters, separated by commas:−
-
- (1) The number of labels across the page (1,2 or 3)
-
- (2) The horizontal label pitch (i.e. left edge to left edge) in inches.
- This is only meaningful when (1) is 2 or 3.
-
- (3) The vertical label pitch in inches.
-
- (4) The number of lines to be printed on each label.
-
- (5) The line which is to be replaced, if blank, by the last field in the
- selection. If nothing is entered here (2 commas together) then no
- substitution is performed.
-
- (6) If ON is entered the the primary key will appear on the label (in
- brackets) as an identifier.
-
- (7) If ON is entered blank fields will be skipped when printing.
-
- !DELETE <key> deletes the record whose primary key is <key>. Suppose you
- have a text file giving details of records to be deleted from the database.
- If such a job is needs doing often it might be worth writing a customised
- program to read the text file, generate the primary key of each record, then
- output the results as a script file with each key preceded by !DELETE. The
- whole batch can then be deleted by simply dragging the script into
- Powerbase. Not worthwhile for ten records, perhaps, but could be for a
- hundred. Note that all 6 subfiles will be searched for the records to be
- deleted.
-
- !INSERT is the counterpart of !DELETE and is useful in similar
- circumstances. In this case the command must occupy a line by itself and be
- followed by the record to insert, one field to a line. It is the user’s
- responsibility to ensure that the lines are not too long for the database
- fields into which they are placed and that the number of lines following
- each !INSERT is the same as the number of fields in the record. Don’t forget
- to leave blank lines for empty fields! Records will be inserted into the
- currently-selected subfile.
-
- !CHANGE <field tag>,<old contents>,<new contents>[,<search formula>] allows
- global changes to be made. The command functions like the Global changes
- menu choice (see 2.5.5).
-
- !IMPRESSION , used in conjunction with !QUERY to generate a report in
- text-file format, allows you to insert Impression DDF* commands at the start
- of the text-file. A script may, for example, execute a series of !QUERY
- commands and the resulting files are to be all selected together and dragged
- into an Impression document. To make each file go into a new frame you need
- to make each begin with {nextframe}. This can be achieved by placing the
- script command !IMPRESSION {nextframe} before the first !QUERY. You do not,
- however, want {nextframe} to begin the first file created, or the Impression
- document will have a blank frame on its first page. To suppress the effect
- on the first file use the form:−
-
- !IMPRESSION {nextframe} Not first
-
- There must be a space between the “}” and the “N”, but the “Not first”
- string isn’t case sensitive.